import React, { Suspense } from "react";
import { BrowserRouter, Switch} from "react-router-dom";
import AuthRoute from "./components/AuthRoute";
import { routes } from "./routes";

const Router = () => {
  return (
    <BrowserRouter>
      <Suspense fallback={'加载中。。。'}>
        <Switch>
          {    /* {   无论route里面有多少个属性，都直接加上了 */
            routes.map((route,index) => {
              return <AuthRoute key={index} {...route} />
            })
          }
        </Switch>
      </Suspense>
    </BrowserRouter>
  );
}

export default Router;
